home *** CD-ROM | disk | FTP | other *** search
- /* A lexical scanner generated by flex */
-
- /* scanner skeleton version:
- * $Header: flex.skel,v 2.0 89/06/20 15:49:46 vern Locked $
- */
-
- #include <stdio.h>
-
- #define FLEX_SCANNER
-
- /* amount of stuff to slurp up with each read */
- #ifndef YY_READ_BUF_SIZE
- #define YY_READ_BUF_SIZE 8192
- #endif
-
- #ifndef YY_BUF_SIZE
- #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of input buffer */
- #endif
-
- /* returned upon end-of-file */
- #define YY_END_TOK 0
-
- /* copy whatever the last rule matched to the standard output */
-
- #define ECHO fputs( yytext, yyout )
-
- /* gets input and stuffs it into "buf". number of characters read, or YY_NULL,
- * is returned in "result".
- */
- #define YY_INPUT(buf,result,max_size) \
- if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
- YY_FATAL_ERROR( "read() in flex scanner failed" );
- #define YY_NULL 0
- #define yyterminate() return ( YY_NULL )
-
- /* report a fatal error */
- #define YY_FATAL_ERROR(msg) \
- { \
- fputs( msg, stderr ); \
- putc( '\n', stderr ); \
- exit( 1 ); \
- }
-
- /* default yywrap function - always treat EOF as an EOF */
- #define yywrap() 1
-
- /* enter a start condition. This macro really ought to take a parameter,
- * but we do it the disgusting crufty way forced on us by the ()-less
- * definition of BEGIN
- */
- #define BEGIN yy_start = 1 + 2 *
-
- /* action number for EOF rule of a given start state */
- #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
-
- /* special action meaning "start processing a new file" */
- #define YY_NEW_FILE goto new_file
-
- /* default declaration of generated scanner - a define so the user can
- * easily add parameters
- */
- #ifdef __STDC__
- #define YY_DECL int yylex( void )
- #else
- #define YY_DECL int yylex()
- #endif
-
- /* code executed at the end of each rule */
- #define YY_BREAK break;
-
- #define YY_END_OF_BUFFER_CHAR 0
-
- /* done after the current pattern has been matched and before the
- * corresponding action - sets up yytext
- */
- #define YY_DO_BEFORE_ACTION \
- yytext = yy_bp; \
- yy_hold_char = *yy_cp; \
- *yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
-
- /* returns the length of the matched text */
- #define yyleng (yy_cp - yy_bp)
-
- #define EOB_ACT_RESTART_SCAN 0
- #define EOB_ACT_END_OF_FILE 1
- #define EOB_ACT_LAST_MATCH 2
-
- /* return all but the first 'n' matched characters back to the input stream */
- #define yyless(n) \
- { \
- *yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \
- yy_c_buf_p = yy_cp = yy_bp + n; \
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
- }
-
- #define unput(c) yyunput( c, yy_bp )
-
- #define YY_USER_ACTION
-
- FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
- char *yytext;
-
- #ifndef __STDC__
- #define const
- #endif
-
- %% section 1 code and the data tables for the DFA go here
-
- /* these variables are all declared out here so that section 3 code can
- * manipulate them
- */
- static char *yy_c_buf_p; /* points to current character in buffer */
- static int yy_init = 1; /* whether we need to initialize */
- static int yy_start = 0; /* start state number */
-
- /* true when we've seen an EOF for the current input file */
- static int yy_eof_has_been_seen;
-
- static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
- /* yy_ch_buf has to be 2 characters longer than YY_BUF_SIZE because we need
- * to put in 2 end-of-buffer characters (this is explained where it is
- * done) at the end of yy_ch_buf
- */
- static char yy_ch_buf[YY_BUF_SIZE + 2];
-
- /* yy_hold_char holds the character lost when yytext is formed */
- static char yy_hold_char;
-
- static yy_state_type yy_last_accepting_state;
- static char *yy_last_accepting_cpos;
-
- #ifdef __STDC__
- static yy_state_type yy_get_previous_state( void );
- static int yy_get_next_buffer( void );
- static void yyunput( int c, char *buf_ptr );
- static int input( void );
- static void yyrestart( FILE *input_file );
- #else
- static yy_state_type yy_get_previous_state();
- static int yy_get_next_buffer();
- static void yyunput();
- static int input();
- static void yyrestart();
- #endif
-
- YY_DECL
- {
- register yy_state_type yy_current_state;
- register char *yy_cp, *yy_bp;
- register int yy_act;
-
- %% user's declarations go here
-
- if ( yy_init )
- {
- if ( ! yy_start )
- yy_start = 1; /* first start state */
-
- if ( ! yyin )
- yyin = stdin;
-
- if ( ! yyout )
- yyout = stdout;
-
- new_file:
- /* this is where we enter upon encountering an end-of-file and
- * yywrap() indicating that we should continue processing
- */
-
- /* we put in the '\n' and start reading from [1] so that an
- * initial match-at-newline will be true.
- */
-
- yy_ch_buf[0] = '\n';
- yy_n_chars = 1;
-
- /* we always need two end-of-buffer characters. The first causes
- * a transition to the end-of-buffer state. The second causes
- * a jam in that state.
- */
- yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- yy_eof_has_been_seen = 0;
-
- yytext = yy_c_buf_p = &yy_ch_buf[1];
- yy_hold_char = *yy_c_buf_p;
- yy_init = 0;
- }
-
- while ( 1 ) /* loops until end-of-file is reached */
- {
- yy_cp = yy_c_buf_p;
-
- /* support of yytext */
- *yy_cp = yy_hold_char;
-
- /* yy_bp points to the position in yy_ch_buf of the start of the
- * current run.
- */
- %% yymore()-related code goes here
-
- %% code to set up and find next match goes here
-
- /* bogus while loop to let YY_BACK_TRACK, EOB_ACT_LAST_MATCH,
- * and EOF actions branch here without introducing an optimizer-
- * daunting goto
- */
- while ( 1 )
- {
- %% code to find the action number goes here
-
- YY_DO_BEFORE_ACTION;
- YY_USER_ACTION;
-
- #ifdef FLEX_DEBUG
- fprintf( stderr, "--accepting rule #%d (\"%s\")\n",
- yy_act, yytext );
- #endif
-
- do_action: /* this label is used only to access EOF actions */
- switch ( yy_act )
- {
- %% actions go here
-
- case YY_END_OF_BUFFER:
- /* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
-
- yytext = yy_bp;
-
- switch ( yy_get_next_buffer() )
- {
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- {
- /* note: because we've taken care in
- * yy_get_next_buffer() to have set up yytext,
- * we can now set up yy_c_buf_p so that if some
- * total hoser (like flex itself) wants
- * to call the scanner after we return the
- * YY_NULL, it'll still work - another YY_NULL
- * will get returned.
- */
- yy_c_buf_p = yytext;
-
- yy_act = YY_STATE_EOF((yy_start - 1) / 2);
- goto do_action;
- }
-
- else
- YY_NEW_FILE;
- }
- break;
-
- case EOB_ACT_RESTART_SCAN:
- yy_c_buf_p = yytext;
- yy_hold_char = *yy_c_buf_p;
- break;
-
- case EOB_ACT_LAST_MATCH:
- yy_c_buf_p = &yy_ch_buf[yy_n_chars];
-
- yy_current_state = yy_get_previous_state();
-
- yy_cp = yy_c_buf_p;
- yy_bp = yytext;
- continue; /* go to "YY_DO_BEFORE_ACTION" */
- }
- break;
-
- default:
- printf( "action # %d\n", yy_act );
- YY_FATAL_ERROR( "fatal flex scanner internal error" );
- }
-
- break; /* exit bogus while loop */
- }
- }
- }
-
-
- /* yy_get_next_buffer - try to read in new buffer
- *
- * synopsis
- * int yy_get_next_buffer();
- *
- * returns a code representing an action
- * EOB_ACT_LAST_MATCH -
- * EOB_ACT_RESTART_SCAN - restart the scanner
- * EOB_ACT_END_OF_FILE - end of file
- */
-
- static int yy_get_next_buffer()
-
- {
- register char *dest = yy_ch_buf;
- register char *source = yytext - 1; /* copy prev. char, too */
- register int number_to_move, i;
- int ret_val;
-
- if ( yy_c_buf_p != &yy_ch_buf[yy_n_chars + 1] )
- {
- YY_FATAL_ERROR( "NULL in input" );
- /*NOTREACHED*/
- }
-
- /* try to read more data */
-
- /* first move last chars to start of buffer */
- number_to_move = yy_c_buf_p - yytext;
-
- for ( i = 0; i < number_to_move; ++i )
- *(dest++) = *(source++);
-
- if ( yy_eof_has_been_seen )
- /* don't do the read, it's not guaranteed to return an EOF,
- * just force an EOF
- */
- yy_n_chars = 0;
-
- else
- {
- int num_to_read = YY_BUF_SIZE - number_to_move - 1;
-
- if ( num_to_read > YY_READ_BUF_SIZE )
- num_to_read = YY_READ_BUF_SIZE;
-
- /* read in more data */
- YY_INPUT( (&yy_ch_buf[number_to_move]), yy_n_chars, num_to_read );
- }
-
- if ( yy_n_chars == 0 )
- {
- if ( number_to_move == 1 )
- ret_val = EOB_ACT_END_OF_FILE;
- else
- ret_val = EOB_ACT_LAST_MATCH;
-
- yy_eof_has_been_seen = 1;
- }
-
- else
- ret_val = EOB_ACT_RESTART_SCAN;
-
- yy_n_chars += number_to_move;
- yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
-
- /* yytext begins at the second character in
- * yy_ch_buf; the first character is the one which
- * preceded it before reading in the latest buffer;
- * it needs to be kept around in case it's a
- * newline, so yy_get_previous_state() will have
- * with '^' rules active
- */
-
- yytext = &yy_ch_buf[1];
-
- return ( ret_val );
- }
-
-
- /* yy_get_previous_state - get the state just before the EOB char was reached
- *
- * synopsis
- * yy_state_type yy_get_previous_state();
- */
-
- static yy_state_type yy_get_previous_state()
-
- {
- register yy_state_type yy_current_state;
- register char *yy_cp;
-
- %% code to get the start state into yy_current_state goes here
-
- for ( yy_cp = yytext; yy_cp < yy_c_buf_p; ++yy_cp )
- {
- %% code to find the next state goes here
- }
-
- return ( yy_current_state );
- }
-
-
- #ifdef __STDC__
- static void yyunput( int c, register char *yy_bp )
- #else
- static void yyunput( c, yy_bp )
- int c;
- register char *yy_bp;
- #endif
-
- {
- register char *yy_cp = yy_c_buf_p;
-
- *yy_cp = yy_hold_char; /* undo effects of setting up yytext */
-
- if ( yy_cp < yy_ch_buf + 2 )
- { /* need to shift things up to make room */
- register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
- register char *dest = &yy_ch_buf[YY_BUF_SIZE + 2];
- register char *source = &yy_ch_buf[number_to_move];
-
- while ( source > yy_ch_buf )
- *--dest = *--source;
-
- yy_cp += dest - source;
- yy_bp += dest - source;
-
- if ( yy_cp < yy_ch_buf + 2 )
- YY_FATAL_ERROR( "flex scanner push-back overflow" );
- }
-
- if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
- yy_cp[-2] = '\n';
-
- *--yy_cp = c;
-
- YY_DO_BEFORE_ACTION; /* set up yytext again */
- }
-
-
- static int input()
-
- {
- int c;
- char *yy_cp = yy_c_buf_p;
-
- *yy_cp = yy_hold_char;
-
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
- { /* need more input */
- yytext = yy_c_buf_p;
- ++yy_c_buf_p;
-
- switch ( yy_get_next_buffer() )
- {
- /* this code, unfortunately, is somewhat redundant with
- * that above
- */
- case EOB_ACT_END_OF_FILE:
- {
- if ( yywrap() )
- {
- yy_c_buf_p = yytext;
- return ( EOF );
- }
-
- yy_ch_buf[0] = '\n';
- yy_n_chars = 1;
- yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
- yy_eof_has_been_seen = 0;
- yytext = yy_c_buf_p = &yy_ch_buf[1];
- yy_hold_char = *yy_c_buf_p;
-
- return ( input() );
- }
- break;
-
- case EOB_ACT_RESTART_SCAN:
- yy_c_buf_p = yytext;
- break;
-
- case EOB_ACT_LAST_MATCH:
- YY_FATAL_ERROR( "unexpected last match in input()" );
- }
- }
-
- c = *yy_c_buf_p;
- yy_hold_char = *++yy_c_buf_p;
-
- return ( c );
- }
-
-
- #ifdef __STDC__
- static void yyrestart( FILE *input_file )
- #else
- static void yyrestart( input_file )
- FILE *input_file;
- #endif
-
- {
- if ( yyin != stdin )
- fclose( yyin );
-
- yyin = input_file;
- yy_init = 1;
- }
-